/**
 * Created by yangfan on 2016/11/12.
 */
/**
 * Created by yangfan on 2016/11/11,
 */
define(['config/appregister',
    'business/careerPlan/services/httpServices',
    "business/services/filter"],function(app,httpService){
    app.directive("downloadRank",function($state){
        return {
            restrict:"A",
            templateUrl:"app/business/services/comComponents/downloadRank.html",
            scope:{
                conf:"=conf"
            },
            link:function(scope,element,attrs){
                //conf ��������˵��
                //@downloadRank �������м���  @type : fileId theisId ...
                scope.downloadRank = scope.conf.data;
                if(scope.downloadRank.length>8){
                    var arr = scope.downloadRank.splice(0,8);
                    scope.downloadRank = arr;
                }
                scope.goToDetail = function(item){
                	if(scope.conf.idType == 'newsId'){
                		$state.go(scope.conf.state,{'newsId':item[scope.conf.idType]},{reload:true});
                	}else if(scope.conf.idType == 'fileId'){
                		$state.go(scope.conf.state,{'fileId':item[scope.conf.idType]},{reload:true});
                	}else if(scope.conf.idType == 'thesisId'){
                		$state.go(scope.conf.state,{'thesisId':item[scope.conf.idType]},{reload:true});
                	}else if(scope.conf.idType == 'postbarId'){
                		$state.go(scope.conf.state,{'postbarId':item[scope.conf.idType]},{reload:true});
                	}else{
                		sessionStorage[scope.conf.idType] = null;
                    	sessionStorage[scope.conf.idType] = item[scope.conf.idType];
                    	$state.go(scope.conf.state,{reload:true});
                	}
                    
                }
            }
        }
    })
});
